/*******************************************************************************
 * Copyright 2010 MoBrite (A venture of Kinara Systems Private Limited)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.mobrite.domaindroid.activity;

import com.mobrite.domaindroid.Constants;
import com.mobrite.domaindroid.R;
import com.mobrite.domaindroid.R.layout;
import com.mobrite.domaindroid.util.Eula;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class MainTabWidget extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
	    setContentView(R.layout.tablayout);
	    //Eula.showDisclaimer(this);
	    Eula.showEula(this);
	    
	    Resources res = getResources(); // Resource object to get Drawables
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, SearchActivity.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("search").setIndicator("Lookup", getResources().getDrawable(R.drawable.ic_tab_lookup))
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, DomainListActivity.class);
	    intent.putExtra(Constants.EXTRA_LIST_TYPE, Constants.LIST_TYPE_AVAILABLE);
	    
	    spec = tabHost.newTabSpec("available").setIndicator("Available", getResources().getDrawable(R.drawable.ic_tab_avail))
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    intent = new Intent().setClass(this, DomainListActivity.class);
	    intent.putExtra(Constants.EXTRA_LIST_TYPE, Constants.LIST_TYPE_TAKEN);
	    spec = tabHost.newTabSpec("taken").setIndicator("Taken", getResources().getDrawable(R.drawable.ic_tab_taken))
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    intent = new Intent().setClass(this, DomainListActivity.class);
	    intent.putExtra(Constants.EXTRA_LIST_TYPE, Constants.LIST_TYPE_FAVORITES);
	    spec = tabHost.newTabSpec("favorites").setIndicator("Favorites", getResources().getDrawable(R.drawable.ic_tab_favorites))
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    tabHost.setCurrentTab(0);

	}
	
}
